import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '发明名称(源文)',
    align: 'center',
    dataIndex: 'originName',
  },
  {
    title: '发明名称(中文)',
    align: 'center',
    dataIndex: 'zhName',
  },
  {
    title: '申请号',
    align: 'center',
    dataIndex: 'applyId',
  },
  {
    title: '申请日',
    align: 'center',
    dataIndex: 'applyDate',
    customRender: ({ text }) => {
      text = !text ? '' : text.length > 10 ? text.substr(0, 10) : text;
      return text;
    },
  },
  {
    title: '申请日(全过程文本)',
    align: 'center',
    dataIndex: 'applyDateAll',
  },
  {
    title: '申请公布号',
    align: 'center',
    dataIndex: 'applyPublicId',
  },
  {
    title: '申请公布日',
    align: 'center',
    dataIndex: 'applyPublicDate',
    customRender: ({ text }) => {
      text = !text ? '' : text.length > 10 ? text.substr(0, 10) : text;
      return text;
    },
  },
  {
    title: '申请公布日(全过程文本)',
    align: 'center',
    dataIndex: 'applyPublicDateAll',
  },
  {
    title: '申请机构名称（源文）',
    align: 'center',
    dataIndex: 'applyInstitutionOriginName',
  },
  {
    title: '申请机构名称（中文）',
    align: 'center',
    dataIndex: 'applyInstitutionZhName',
  },
  {
    title: '发明人名称（源文）',
    align: 'center',
    dataIndex: 'inventorOriginName',
  },
  {
    title: '发明人名称（中文）',
    align: 'center',
    dataIndex: 'inventorZhName',
  },
  {
    title: '地址(字符串原文）',
    align: 'center',
    dataIndex: 'address',
  },
  {
    title: '代理机构名称（源文）',
    align: 'center',
    dataIndex: 'agentInstitutionOriginName',
  },
  {
    title: '代理机构名称（中文）',
    align: 'center',
    dataIndex: 'agentInstitutionZhName',
  },
  {
    title: '代理人（源文）',
    align: 'center',
    dataIndex: 'agentOriginName',
  },
  {
    title: '代理人（中文）',
    align: 'center',
    dataIndex: 'agentZhName',
  },
  {
    title: 'IPC分类号',
    align: 'center',
    dataIndex: 'ipcClassId',
  },
  {
    title: '国际分类号',
    align: 'center',
    dataIndex: 'internetClassId',
  },
  {
    title: '摘要（源文）',
    align: 'center',
    dataIndex: 'summary',
  },
  {
    title: '摘要（中文）',
    align: 'center',
    dataIndex: 'summaryZh',
  },
  {
    title: '文件',
    align: 'center',
    dataIndex: 'fileString',
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '发明名称(源文)',
    field: 'originName',
    component: 'JInput',
    colProps: { span: 12 },
  },
  {
    label: '发明名称(中文)',
    field: 'zhName',
    component: 'JInput',
    colProps: { span: 12 },
  },
  {
    label: '申请号',
    field: 'applyId',
    component: 'Input',
    colProps: { span: 12 },
  },
  {
    label: '申请日',
    field: 'applyDate',
    component: 'RangePicker',
    componentProps: {
      valueType: 'Date',
    },
    colProps: { span: 12 },
  },
  {
    label: '申请公布日',
    field: 'applyPublicDate',
    component: 'RangePicker',
    componentProps: {
      valueType: 'Date',
    },
    colProps: { span: 12 },
  },
  {
    label: '申请机构名称(源文)',
    field: 'applyInstitutionOriginName',
    component: 'JInput',
    colProps: { span: 12 },
  },
  {
    label: '申请机构名称(中文)',
    field: 'applyInstitutionZhName',
    component: 'JInput',
    colProps: { span: 12 },
  },
  {
    label: '地址(字符串原文)',
    field: 'address',
    component: 'JInput',
    colProps: { span: 12 },
  },
  {
    label: '代理机构名称(源文)',
    field: 'agentInstitutionOriginName',
    component: 'JInput',
    colProps: { span: 12 },
  },
  {
    label: '代理机构名称(中文)',
    field: 'agentInstitutionZhName',
    component: 'JInput',
    colProps: { span: 12 },
  },
  {
    label: '代理人(源文)',
    field: 'agentOriginName',
    component: 'JInput',
    colProps: { span: 12 },
  },
  {
    label: 'IPC分类号',
    field: 'ipcClassId',
    component: 'JInput',
    colProps: { span: 12 },
  },
  {
    label: '国际分类号',
    field: 'internetClassId',
    component: 'JInput',
    colProps: { span: 12 },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '发明名称(源文)',
    field: 'originName',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入发明名称(源文)!' }];
    },
  },
  {
    label: '发明名称(中文)',
    field: 'zhName',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入发明名称(中文)!' }];
    },
  },
  {
    label: '申请号',
    field: 'applyId',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入申请号!' }];
    },
  },
  {
    label: '申请日',
    field: 'applyDate',
    component: 'DatePicker',
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
    },
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入申请日!' }];
    },
  },
  {
    label: '申请日(全过程文本)',
    field: 'applyDateAll',
    component: 'Input',
  },
  {
    label: '申请公布号',
    field: 'applyPublicId',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入申请公布号!' }];
    },
  },
  {
    label: '申请公布日',
    field: 'applyPublicDate',
    component: 'DatePicker',
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
    },
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入申请公布日!' }];
    },
  },
  {
    label: '申请公布日(全过程文本)',
    field: 'applyPublicDateAll',
    component: 'Input',
  },
  {
    label: '申请机构名称（源文）',
    field: 'applyInstitutionOriginName',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入申请机构名称（源文）!' }];
    },
  },
  {
    label: '申请机构名称（中文）',
    field: 'applyInstitutionZhName',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入申请机构名称（中文）!' }];
    },
  },
  {
    label: '发明人名称（源文）',
    field: 'inventorOriginName',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入发明人名称（源文）!' }];
    },
  },
  {
    label: '发明人名称（中文）',
    field: 'inventorZhName',
    component: 'Input',
  },
  {
    label: '地址(字符串原文）',
    field: 'address',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入地址(字符串原文）!' }];
    },
  },
  {
    label: '代理机构名称（源文）',
    field: 'agentInstitutionOriginName',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入代理机构名称（源文）!' }];
    },
  },
  {
    label: '代理机构名称（中文）',
    field: 'agentInstitutionZhName',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入代理机构名称（中文）!' }];
    },
  },
  {
    label: '代理人（源文）',
    field: 'agentOriginName',
    component: 'Input',
  },
  {
    label: '代理人（中文）',
    field: 'agentZhName',
    component: 'Input',
  },
  {
    label: 'IPC分类号',
    field: 'ipcClassId',
    component: 'Input',
  },
  {
    label: '国际分类号',
    field: 'internetClassId',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入国际分类号!' }];
    },
  },
  {
    label: '摘要（源文）',
    field: 'summary',
    component: 'JEditor',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入摘要（源文）!' }];
    },
  },
  {
    label: '摘要（中文）',
    field: 'summaryZh',
    component: 'Input',
  },
  {
    label: '文件',
    field: 'fileString',
    component: 'JUpload',
    componentProps: {},
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入文件!' }];
    },
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  originName: { title: '发明名称(源文)', order: 0, view: 'text', type: 'string' },
  zhName: { title: '发明名称(中文)', order: 1, view: 'text', type: 'string' },
  applyId: { title: '申请号', order: 2, view: 'text', type: 'string' },
  applyDate: { title: '申请日', order: 3, view: 'date', type: 'string' },
  applyDateAll: { title: '申请日(全过程文本)', order: 4, view: 'text', type: 'string' },
  applyPublicId: { title: '申请公布号', order: 5, view: 'text', type: 'string' },
  applyPublicDate: { title: '申请公布日', order: 6, view: 'date', type: 'string' },
  applyPublicDateAll: { title: '申请公布日(全过程文本)', order: 7, view: 'text', type: 'string' },
  applyInstitutionOriginName: { title: '申请机构名称（源文）', order: 8, view: 'text', type: 'string' },
  applyInstitutionZhName: { title: '申请机构名称（中文）', order: 9, view: 'text', type: 'string' },
  inventorOriginName: { title: '发明人名称（源文）', order: 10, view: 'text', type: 'string' },
  inventorZhName: { title: '发明人名称（中文）', order: 11, view: 'text', type: 'string' },
  address: { title: '地址(字符串原文）', order: 12, view: 'text', type: 'string' },
  agentInstitutionOriginName: { title: '代理机构名称（源文）', order: 13, view: 'text', type: 'string' },
  agentInstitutionZhName: { title: '代理机构名称（中文）', order: 14, view: 'text', type: 'string' },
  agentOriginName: { title: '代理人（源文）', order: 15, view: 'text', type: 'string' },
  agentZhName: { title: '代理人（中文）', order: 16, view: 'text', type: 'string' },
  ipcClassId: { title: 'IPC分类号', order: 17, view: 'text', type: 'string' },
  internetClassId: { title: '国际分类号', order: 18, view: 'text', type: 'string' },
  summary: { title: '摘要（源文）', order: 19, view: 'text', type: 'string' },
  summaryZh: { title: '摘要（中文）', order: 20, view: 'text', type: 'string' },
  file: { title: '文件', order: 21, view: 'file', type: 'string' },
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
